/**
 * Created by TangZK on 2015/6/17.
 */

var User = (function () {
	function Module() {
		this.uid = null;
		this.username = null;
		this.access_time = null;
		this.role = null;
		this.ip = null;
		this.join_id = null; //uid有为零的情况，所以需要使用join_id做为用户的唯一标记
		this.status = 0; //默认为在线，2为离线，3为转接
	}

	Module.prototype.getUserInfo = function (url, fn) {
		$.ajax({
			url: url,
			dataType: 'json',
			type: 'GET',
			success: function (resp) {
				if (resp && resp.code == 1) {
					fn && fn.call(this, resp);
				}
			}
		});
	};

	Module.prototype.getMyInfo = function() {
		var uo = {};
		uo.uid = this.uid;
		uo.username = this.username;
		uo.access_time = this.access_time;
		uo.role = this.role;
		uo.ip = this.ip;
		uo.join_id = this.join_id;
		uo.status = this.status;
		return uo;
	};

	Module.prototype.setUserInfo = function (uo) {
		this.uid = uo.uid;
		this.username = uo.username;
		this.access_time = uo.access_time;
		this.role = uo.role;
		this.ip = uo.ip;
		this.join_id = uo.join_id;
		this.status = uo.status;
	};

	return Module;
})();